using MicroMsg.Common.Event;
using System;
using System.Collections.Generic;
namespace MicroMsg.Manager
{
	public class LanguageRefreshManager
	{
		private static LanguageRefreshManager instance;
		private EventWatcher mWatcherLanguageChange;
		public List<LanguageListener> mDataList = new List<LanguageListener>();
		public static LanguageRefreshManager GetInstance()
		{
			if (LanguageRefreshManager.instance == null)
			{
				LanguageRefreshManager.instance = new LanguageRefreshManager();
			}
			return LanguageRefreshManager.instance;
		}
		private LanguageRefreshManager()
		{
			this.InitLanguageChange();
		}
		private void InitLanguageChange()
		{
			this.mWatcherLanguageChange = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventHandlerLanguageChange));
			EventCenter.registerEventWatcher(EventConst.ON_UI_LANGUAGE_CHANGED, this.mWatcherLanguageChange);
		}
		private void onEventHandlerLanguageChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			using (List<LanguageListener>.Enumerator enumerator = this.mDataList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					LanguageListener current = enumerator.get_Current();
					if (current != null)
					{
						current.OnLanguageChange();
					}
				}
			}
		}
		public void Add(LanguageListener languageListener)
		{
			if (languageListener == null)
			{
				return;
			}
			if (this.mDataList.Contains(languageListener))
			{
				return;
			}
			if (languageListener == null)
			{
				return;
			}
			this.mDataList.Add(languageListener);
		}
		public void Delete(LanguageListener languageListener)
		{
			if (languageListener == null)
			{
				return;
			}
			if (this.mDataList == null)
			{
				return;
			}
			if (!this.mDataList.Contains(languageListener))
			{
				return;
			}
			this.mDataList.Remove(languageListener);
		}
	}
}
